<?php
/**
 * | @author 韩威兵^life <1877361302@qq.com>
 * +----------------------------------------------------------------------
 * | @copyright 2016 - 2019 HQ
 * +----------------------------------------------------------------------
 * | @version $Id: 2019/5/22 11:57 jiahe_new OrderServer.php 韩威兵^life $
 * +----------------------------------------------------------------------
 */

namespace app\api\server\order;

class  OrderServer{

    public static $error = '';

    /**
     * 确认订单
     * @param $data
     * @return bool
     */
    public function confirmOrder($data){
        $domain = config('old_url');
        $url = $domain.'/home/order/getCouponList';
        $result = postcurl($url, $data);
        aw_log($data, 'confirmOrder.log');
        aw_log($result, 'confirmOrder.log');
        if(empty($result)){
            $data['msg'] = '数据获取失败';
            self::$error = json_encode($data);
            return false;
        }
        $result = json_decode($result, true);
        aw_log($result, 'confirmOrder.log');

        //if(!isset($result['data']) || !is_array($result['data'])){
        //
        //}
        if($result['code'] == 0){
            return $result['data']?:[];
        }else{
            $msg = is_array($result['data'])?$result['data']['msg']:$result['data'];
            $data['msg'] = $msg;
            self::$error = json_encode($data);
            return false;
        }
    }
}  